package Operations;

import Book.BookList;

import java.util.Scanner;

public class Back implements Ioperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入将要归还的书名：");
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.Size; i++) {
            if(name.compareTo(bookList.books[i].getName()) == 0){
                if(bookList.books[i].isIsborrow()){
                    bookList.books[i].setIsborrow(false);
                    System.out.println("归还书籍成功！");
                    return;
                }else {
                    System.out.println("书籍未借阅，无法归还！");
                    return;
                }
            }
        }
        System.out.println("未找到该书籍，无法归还！");
    }
}
